// pages/carstore/confirmorder.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
	  totalprice:"",
	  activity: ["省10元", "省20元","省30元"],
	  delivery:["快递(包邮)","顺丰快递(15元)"],
	  index1: 0,
	  index2: 0,
	  user: { address: "福建省 厦门市 思明区 马青路 东西巷 1223号 23楼 1233室", name: "王力宏", phone: "13844332255" },
	  product: [
		  { img: "/images/product1.png", name: "一品轩皇家789008909820-3有机军用机油", price: "78.00", num: 2 },
		  {  img: "/images/product1.png", name: "一品轩皇家789008909820-3有机军用机油",  price: "78.00", num: 2 },
		  { img: "/images/product1.png", name: "一品轩皇家789008909820-3有机军用机油", price: "78.00", num: 2 }
	  ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
	  var that = this;
	var price=0;
	var num=0;
	  let product = this.data.product;
	  for (let i = 0; i < product.length;i++){
		   price += product[i].price*product[i].num
		  num += product[i].num
	  }
	  this.setData({
		  totalprice: price,
		  totalnum:num
	  })

  },
	activity: function (e) {
		this.setData({
			index1: e.detail.value,
		})
	},
	delivery:function(e){
		this.setData({
			index2: e.detail.value,
		})
	}
})